Python Bookcamp: Exercises and Projects by Sarcar Vaskaran & Sarcar Vaskaran

Python Bookcamp: Exercises and Projects by Sarcar Vaskaran & Sarcar Vaskaran

Author:Sarcar, Vaskaran & Sarcar, Vaskaran [Sarcar, Vaskaran]
Language: eng
Format: epub
Published: 2021-01-24T00:00:00+00:00


print("The initial_list is :")

print(initial_list)

print("Calling the function make_double() now.")

make_double(initial_list)

print("The double_list is :")

print(double_list)

print("The initial_list at present :")

print(initial_list) #unchanged initial list

Output

Here is the output.

The initial_list is :

[1, 2, 3, 4, 5]

Calling the function make_double() now.

The double_list is :

[2, 4, 6, 8, 10]

The initial_list at present :

[1, 2, 3, 4, 5]

Demonstration 5

In the previous demonstration, you did not modify the original list. But in some cases, once you create a new list, you do not need to maintain the old/original list. But keep in mind that this can be risky.

The following demonstration shows you such an example, where you remove the elements from the initial list, make them double, and create a new list. So, in the end, when you print the original list, you’ll see that the initial list is empty.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.